<%@page import="com.wodwl.entity.Category"%>
<%@page import="java.util.List"%>
<%@page import="com.wodwl.entity.Blog"%>
<%@page import="com.wodwl.entity.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<%@include file="../templete/head.jsp"  %>
	<script type="text/javascript" src="../../static/ckeditor/ckeditor.js"></script>
	
	<style type="text/css">
		.content{
			margin-top: 5px;
			
		}
		.content .item{
			height: 40px;
		}
		.content .title{
			padding-top: 10px;
		}
		.content .label{
			font-size: 16px;
		}
		.content input{
			width: 240px;
			height: 20px;
		}
		.content .submit_btn{
			margin:10px auto;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function(){
			$(".submit_btn").button();
			$(".submit_btn").click(function(){
				submit();
			});
		});
		
		function submit(){
			$(".myform").submit();
		}
	</script>
</head>
<body >
	<%pageContext.setAttribute("linkType", "6");%>
	<%@include file="../templete/banner.jsp"  %>
	<%Blog blog = (Blog) request.getAttribute("blog");%>

	

	<div class="mainRight">
		<div class="mainRightBar">
				<div class="title">编辑博客</div>
				<div class="myblog_btn btn" >我的博客</div>
				<div class="blog_category_btn btn">博客分类</div>
				<div class="blog_list_btn btn" >博客列表</div>
				<div class="write_blog_btn btn" >写博客</div>
		</div>
		<div class="content">
			<form action="/blog/blog_editor2.do" method="post" class="myform">

				<input type="hidden" name="username" value="<%=user.getUsername() %>" >
				<input type="hidden" name="bid" value="<%=blog.getBid()%>">
					<div class="item title">
						<span class="label">标题：</span>
						<span><input type="text" name="title" value="<%=blog.getTitle()%>"></span>
					</div>
					<div class="item category">
						<span class="label">分类：</span>
						<span>
								<%
							List<Category> categories=(List<Category>)request.getAttribute("categories");
							if(categories!=null&&categories.size()>0){
							%>
							<select name="cid">
								<%for(int i=0;i<categories.size();i++){
									Category item=categories.get(i);
									if(item.getCid()==blog.getCid()){
								%>
								<option value="<%=item.getCid()%>" selected="selected"><%=item.getCname() %></option>
								<%} else{%>
								<option value="<%=item.getCid()%>"><%=item.getCname() %></option>
								<%}} %>
							</select>
							<%}else{%>
								<a href="/blog/category_list.do">添加分类</a>
							<%} %>
						</span>
					</div>
					
					<div>
						<textarea name="content"  id="content"><%=blog.getContent()%></textarea>	
					</div>
					<div class="submit_btn">
						发表
					</div>

				<script type="text/javascript">
					CKEDITOR.replace("content", {
						skin : "kama",
						width : 800,
						height : 400
					});
				</script>
			</form>
		</div>

		<p class=" divPage">
			<span class="cur">1</span> <a href="#" class="item">2</a> <a
				href="#" class="item">3</a> <a class="item" href="#">下一页</a>
		</p>
	</div>
</div>

<%@include file="../templete/footer.jsp"  %>
	
<script type="text/javascript">
	$(document).ready(function(){
		$(".btn").button();
		
		$(".write_blog_btn").click(function(){
			window.location.href="/blog/blog_add_view.do";
		});
		$(".blog_list_btn").click(function(){
			window.location.href="/blog/blog_list.do";
		});
		$(".blog_category_btn").click(function(){
			window.location.href="/blog/category_list.do";
		});
		$(".myblog_btn").click(function(){
			window.location.href="#";
		});
		
	});
</script>
</body>
</html>